#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>

typedef enum {
    MAN,
    WOMAN
} SEX;

typedef struct AddressBook {
    int id;
    char name[20];
    SEX sex;
    char phone[12];
    struct AddressBook *next;
} AddressBook;

typedef struct Login {
    char name[20];
    char passwd[20];
    struct Login *next;
} Login;

void add_contact(AddressBook **head, int *count);
void search_contact(const AddressBook *head);
void modify_contact(AddressBook *head);
void delete_contact(AddressBook **head, int *count);
void insert_contact(AddressBook **head, int *count);
void show_all_contacts(const AddressBook *head);
void export_contacts(const AddressBook *head);
void sort_contacts(AddressBook *head);
void free_all_contacts(AddressBook **head);

void register_user(Login **login_list, int *lg_count);
int login_user(const Login *login_list);
void free_all_logins(Login **login_list);

int read_contacts_from_file(const char *filename, AddressBook **head);
int read_logins_from_file(const char *filename, Login **login_list);
